
"""
    进程的名称，编号，父id，结束进程
"""
import time
import multiprocessing
import os


def work1():

    for i in range(5):
        print("work1---")
        time.sleep(1)


if __name__ == '__main__':
    process1 = multiprocessing.Process(target=work1)

    # 获取进程的名称
    print(multiprocessing.current_process())

    # 获取进程的编号
    print(multiprocessing.current_process().pid)
    print(os.getpid())

    # 获取进程的父id
    print(os.getppid())

    # 设定线程子进程守护主进程
    # process1.daemon = True

    process1.start()

    # 终止子进程的执行
    process1.terminate()



